import "./App.css";
import React, { useState } from "react";
import Logs from "./Components/Logs";
import LogForm from "./Components/LogForm/LogForm";
const App = () => {
  const [logsData, setLogsData] = useState([
    {
      id: "1",
      date: new Date(2021, 2, 26, 19, 0),
      desc: "学习Nest",
      time: "50"
    },
    {
      id: "2",
      date: new Date(2022, 5, 16, 6, 30),
      desc: "学习vue",
      time: "80"
    },
    {
      id: "3",
      date: new Date(2023, 12, 26, 12, 30),
      desc: "学习React",
      time: "60"
    }
  ]);
  const saveLogHandler = (newLog) => {
    // 添加个id
    newLog.id = (logsData.length + 1).toString();
    setLogsData([...logsData, newLog]);
    console.log("日志数据", logsData);
  };
  return (
    <div className="App">
      <LogForm onSaveLog={saveLogHandler} />
      <Logs logsData={logsData} />
    </div>
  );
};

export default App;
